Skip to content

Commit 38d8dfc

Browse files
committed
Added Windows binary distrubtion creation
1 parent f6c95ca commit 38d8dfc

File tree

5 files changed

+178
-14
lines changed

5 files changed

+178
-14
lines changed

LICENSE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
as4.c, label.c, num.c, and output.c are released under The Unlicense detailed below.
2+
13
This is free and unencumbered software released into the public domain.
24

35
Anyone is free to copy, modify, publish, use, compile, sell, or
@@ -23,3 +25,4 @@ OTHER DEALINGS IN THE SOFTWARE.
2325

2426
For more information, please refer to <http://unlicense.org>
2527

28+
getline.c is used under the terms of the GPL2. It is only used for the Windows binary distribution.

Makefile

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
1-
SRC=as4.c num.c label.c output.c
21
EXE=as4
3-
EXTRACFLAGS=
4-
EXTRALDFLAGS=
5-
export SRC
6-
export EXE
7-
export EXTRACFLAGS
8-
export EXTRALDFLAGS
9-
2+
SRCDIR=src
103
all: fast
114

125

136
fast: phony
14-
$(MAKE) -C src fast
15-
cp src/as4 .
7+
$(MAKE) -C $(SRCDIR) fast
8+
cp $(SRCDIR)/$(EXE) .
169

1710
debug: phony
1811
$(MAKE) -C src
19-
cp src/as4 .
12+
cp $(SRCDIR)/$(EXE) .
13+
14+
distw32: phony
15+
$(MAKE) -C $(SRCDIR) distw32
16+
cp $(SRCDIR)/$(EXE) .
2017

2118
clean:
22-
$(MAKE) -C src clean
23-
rm -rf as4 gmon.out
19+
$(MAKE) -C $(SRCDIR) clean
20+
rm -rf $(EXE) gmon.out
2421

2522
phony:
2623
true

src/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ fast: phony
1515
debug: phony
1616
$(MAKE) -f Makefile.dev.gcc
1717

18+
distw32: phony
19+
$(MAKE) -f Makefile.dist.mingw32
20+
1821
clean:
19-
rm -rf $(SRC:.c=.gcno) $(SRC:.c=.gcda) $(SRC:.c=.gcov) $(SRC:.c=.o)
22+
rm -rf $(SRC:.c=.gcno) $(SRC:.c=.gcda) $(SRC:.c=.gcov) $(SRC:.c=.o) getline.o
2023
rm -rf html gmon.out docs.html $(EXE) *.dyn *.dpi *.lock *.stackdump *.db
2124

2225
phony:

src/Makefile.dist.mingw32

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CC=i686-pc-mingw32-gcc
2+
FASTFLAGS=-m32 -Os -s -static -march=native -fomit-frame-pointer -pipe -Wdisabled-optimization
3+
CFLAGS=$(FASTFLAGS) $(EXTRACFLAGS) -c
4+
LDFLAGS=$(FASTFLAGS) $(EXTRALDFLAGS)
5+
SRC+=getline.c
6+
OBJ=$(SRC:.c=.o)
7+
8+
all: $(SRC) $(EXE)
9+
10+
$(EXE): $(OBJ)
11+
$(CC) $(OBJ) -o $@ $(LDFLAGS)
12+
13+
%.o: %.c
14+
$(CC) $(CFLAGS) $< -o $@

src/getline.c

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/* getline.c -- Replacement for GNU C library function getline
2+
3+
Copyright (C) 1993 Free Software Foundation, Inc.
4+
5+
This program is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU General Public License as
7+
published by the Free Software Foundation; either version 2 of the
8+
License, or (at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful, but
11+
WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
General Public License for more details. */
14+
15+
/* Written by Jan Brittenson, bson@gnu.ai.mit.edu. */
16+
17+
/* From http://www.opensource.apple.com/source/cvs/cvs-19/cvs/lib/getline.c?txt */
18+
19+
#ifdef HAVE_CONFIG_H
20+
#include <config.h>
21+
#endif
22+
23+
#include <sys/types.h>
24+
#include <stdio.h>
25+
#include <assert.h>
26+
#include <errno.h>
27+
28+
#if STDC_HEADERS
29+
#include <stdlib.h>
30+
#else
31+
char *malloc (), *realloc ();
32+
#endif
33+
34+
/* Always add at least this many bytes when extending the buffer. */
35+
#define MIN_CHUNK 64
36+
37+
/* Read up to (and including) a TERMINATOR from STREAM into *LINEPTR
38+
+ OFFSET (and null-terminate it). *LINEPTR is a pointer returned from
39+
malloc (or NULL), pointing to *N characters of space. It is realloc'd
40+
as necessary. Return the number of characters read (not including the
41+
null terminator), or -1 on error or EOF. On a -1 return, the caller
42+
should check feof(), if not then errno has been set to indicate
43+
the error. */
44+
45+
int
46+
getstr (lineptr, n, stream, terminator, offset)
47+
char **lineptr;
48+
size_t *n;
49+
FILE *stream;
50+
char terminator;
51+
int offset;
52+
{
53+
int nchars_avail; /* Allocated but unused chars in *LINEPTR. */
54+
char *read_pos; /* Where we're reading into *LINEPTR. */
55+
int ret;
56+
57+
if (!lineptr || !n || !stream)
58+
{
59+
errno = EINVAL;
60+
return -1;
61+
}
62+
63+
if (!*lineptr)
64+
{
65+
*n = MIN_CHUNK;
66+
*lineptr = malloc (*n);
67+
if (!*lineptr)
68+
{
69+
errno = ENOMEM;
70+
return -1;
71+
}
72+
}
73+
74+
nchars_avail = *n - offset;
75+
read_pos = *lineptr + offset;
76+
77+
for (;;)
78+
{
79+
int save_errno;
80+
register int c = getc (stream);
81+
82+
save_errno = errno;
83+
84+
/* We always want at least one char left in the buffer, since we
85+
always (unless we get an error while reading the first char)
86+
NUL-terminate the line buffer. */
87+
88+
assert((*lineptr + *n) == (read_pos + nchars_avail));
89+
if (nchars_avail < 2)
90+
{
91+
if (*n > MIN_CHUNK)
92+
*n *= 2;
93+
else
94+
*n += MIN_CHUNK;
95+
96+
nchars_avail = *n + *lineptr - read_pos;
97+
*lineptr = realloc (*lineptr, *n);
98+
if (!*lineptr)
99+
{
100+
errno = ENOMEM;
101+
return -1;
102+
}
103+
read_pos = *n - nchars_avail + *lineptr;
104+
assert((*lineptr + *n) == (read_pos + nchars_avail));
105+
}
106+
107+
if (ferror (stream))
108+
{
109+
/* Might like to return partial line, but there is no
110+
place for us to store errno. And we don't want to just
111+
lose errno. */
112+
errno = save_errno;
113+
return -1;
114+
}
115+
116+
if (c == EOF)
117+
{
118+
/* Return partial line, if any. */
119+
if (read_pos == *lineptr)
120+
return -1;
121+
else
122+
break;
123+
}
124+
125+
*read_pos++ = c;
126+
nchars_avail--;
127+
128+
if (c == terminator)
129+
/* Return the line. */
130+
break;
131+
}
132+
133+
/* Done - NUL terminate and return the number of chars read. */
134+
*read_pos = '\0';
135+
136+
ret = read_pos - (*lineptr + offset);
137+
return ret;
138+
}
139+
140+
int
141+
getline (lineptr, n, stream)
142+
char **lineptr;
143+
size_t *n;
144+
FILE *stream;
145+
{
146+
return getstr (lineptr, n, stream, '\n', 0);
147+
}

0 commit comments

Comments
 (0)