1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
# The installation prefix
PREFIX=/usr/local
GCC_VERSION!=gcc -dumpversion
CC=gcc
CFLAGS =-std=c11 -g -fno-common -Wall -Wno-switch -DPREFIX=\"$(PREFIX)\" -DGCC_VERSION=\"$(GCC_VERSION)\"
CFLAGS_DIAG= -std=c11
OBJECT=chibicc
OBJECTLIB=libchibicc
SRCS=$(wildcard *.c)
OBJS=$(SRCS:.c=.o)
TEST_SRCS=$(wildcard test/*.c)
TESTS=$(TEST_SRCS:.c=.exe)
ISSUES_SRCS=$(wildcard issues/*.c)
#PNG=$(TEST_SRCS:.c=.tmp)
#PNG2=$(ISSUES_SRCS:.c=.tmp)
# Stage 1
$(OBJECT): $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(OBJS): $(OBJECT).h
test/%.exe: $(OBJECT) test/%.c
./$(OBJECT) $(CFLAGS_DIAG) -Iinclude -Itest -c -o test/$*.o test/$*.c
$(CC) -pthread -o $@ test/$*.o -xc test/common -lm
# dot -Tpng test/$*.dot -o diagram/$*.png || echo $*.dot failed
test: $(TESTS)
for i in $^; do echo $$i; ./$$i || exit 1; echo; done
test/driver.sh ./$(OBJECT)
# #for managing dot diagram
# test-png: $(TESTS)
test-all: test test-stage2
# Stage 2
stage2/$(OBJECT): $(OBJS:%=stage2/%)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
stage2/%.o: $(OBJECT) %.c
mkdir -p stage2/test
./chibicc -c -o $(@D)/$*.o $*.c
stage2/test/%.exe: stage2/$(OBJECT) test/%.c
mkdir -p stage2/test
./stage2/$(OBJECT) -Iinclude -Itest -c -o stage2/test/$*.o test/$*.c
$(CC) -pthread -o $@ stage2/test/$*.o -xc test/common
test-stage2: $(TESTS:test/%=stage2/test/%)
for i in $^; do echo $$i; ./$$i || exit 1; echo; done
test/driver.sh ./stage2/$(OBJECT)
projects-all: projects projects-oth lxc vlc git memcached cpython openssl
projects-oth: vim nmap curl
projects: zlib util-linux nginx
curl:
cd ../curl && make clean && CC=chibicc CFLAGS="-std=c11" ./configure --with-openssl && make && make test
zlib:
cd ../zlib && make clean && CC=chibicc CFLAGS="-fPIC -std=c11" ./configure && make && make test
nmap:
cd ../nmap && make clean && CC=chibicc CFLAGS="-fPIC -std=c11" LIBS="-ldbus-1 -latomic -libverbs -lrdmacm" ./configure --with-dbus && make && make check
openssl:
cd ../openssl && make clean && CC=chibicc CFLAGS="-std=c11" ./Configure && make
util-linux:
cd ../util-linux && make clean && CC=chibicc CFLAGS="-fPIC -std=c11" ./configure && make && make check-programs && cd tests && ./run.sh
nginx:
cd ../nginx && make clean && CC=chibicc CFLAGS="-fPIC -std=c11" ./auto/configure --with-http_ssl_module && make
vim:
cd ../vim && make clean && CC=chibicc CFLAGS="-fPIC -std=c11" ./configure && make && make test
lxc:
cd ../lxc && rm -rf build && CC=gcc \
meson setup build && cd build && sudo cp /usr/bin/gcc /usr/bin/gcc_backup && \
sudo cp /usr/local/bin/chibicc /usr/bin/gcc && meson compile && sudo cp /usr/bin/gcc_backup /usr/bin/gcc
vlc:
cd ../vlc && make clean && CC=chibicc CFLAGS="-fPIC -std=c11" ./configure \
--disable-lua --disable-xcb --disable-qt --disable-alsa --disable-sse --host x86_64-linux-gnu && \
make all
cpython:
cd ../cpython && CC=chibicc ./configure \
--build=x86_64-pc-linux-gnu ac_cv_have_lchflags=no ac_cv_have_chflags=no && make && make test
# vlc2:
# cd ../vlc && rm -rf build && mymeson setup build && cd build && mymeson compile
git:
cd ../git && CC=chibicc CFLAGS="-fPIC -std=c11" ./configure && make && make test
memcached:
cd ../memcached && make clean && CC=chibicc CFLAGS="-fPIC -std=c11" ./configure && make && make test
openssh-portable:
cd ../openssh-portable && make clean && CC=chibicc CFLAGS="-std=c11" ./configure && make && make tests
# Misc.
libchibicc: $(OBJECT) $(OBJECTLIB).so
CFLAGS +=-fPIC
libchibicc.so: $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ -shared
clean:
rm -rf $(OBJECT) tmp* $(TESTS) issues/*.s issues/*.exe issues/*.dot test/*.s test/*.exe stage2 diagram/*.png test/*.dot $(OBJECTLIB)
find * -type f '(' -name '*~' -o -name '*.o' ')' -exec rm {} ';'
install: $(OBJECT)
install -v -D -m 755 -t $(PREFIX)/bin/ $(OBJECT)
install -v -D -m 644 -t $(PREFIX)/include/x86_64-linux-gnu/chibicc/ include/*
uninstall:
rm -f $(PREFIX)/bin/chibicc
rm -f $(PREFIX)/include/x86_64-linux-gnu/chibicc/*
.PHONY: test clean test-stage2 libchibicc projects projects-all projects-oth test-all install uninstall
|