You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
856 B

SRC:=src/*.c
INCLUDE:=include/
CFLAGS:=-g -Wall -pedantic
LFLAGS:=
BUILD:=build
OBJ:=obj
TEST_SRC:=src/test/main.c
ifeq ($(shell uname), Linux)
TARGET_TEST_EXT =
else
TARGET_TEST_EXT = .exe
endif
all: clean test
clean:
rm -f $(BUILD)/*
rm -f $(OBJ)/*
liblist:
gcc -c $(CFLAGS) -I$(INCLUDE) $(SRC)
mv *.o $(OBJ)/
ar rcs $(BUILD)/$@.a $(OBJ)/*.o
test: liblist
gcc $(TEST_SRC) $(CFLAGS) -I$(INCLUDE) -o $(BUILD)/$@$(TARGET_TEST_EXT) $(LFLAGS) $(BUILD)/liblist.a
$(BUILD)/$@$(TARGET_TEST_EXT)
install:
cp $(BUILD)/*.a /usr/local/lib/
cp $(INCLUDE)/*.h /usr/local/include/
ln -sf /usr/local/lib/liblist.a /usr/lib/liblist.a
ln -sf /usr/local/include/list.h /usr/include/list.h
uninstall:
rm /usr/local/lib/liblist.a
rm /usr/local/include/list.h
rm /usr/lib/liblist.a
rm /usr/include/list.h