1 # Makefile - Build the filesystem access programs 2 # 3 # Copyright (C) 2019, 2021 Paul Boddie <paul@boddie.org.uk> 4 # 5 # This program is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 # Paths to library sources. 19 20 INC = ../include/e2access 21 SRC = ../lib/src 22 23 # Tool definitions. 24 25 RANLIB = ranlib 26 27 # Compilation and linking flags. 28 29 CFLAGS = -I$(INC) # -g 30 LDFLAGS = -lext2fs -L. -le2access # -lcom_err 31 32 # Output programs and libraries. 33 34 E2ACCESS = e2access 35 LIBE2ACCESS = libe2access.a 36 LIBE2ACCESS_SHARED = libe2access.so 37 38 TEST_LISTING = test_listing 39 TEST_REMOVE = test_remove 40 41 TARGETS = $(E2ACCESS) $(LIBE2ACCESS) $(LIBE2ACCESS_SHARED) $(TEST_LISTING) $(TEST_REMOVE) 42 43 # Sources and objects. 44 45 E2ACCESS_SRC = e2access.c file.c 46 E2ACCESS_OBJ = $(E2ACCESS_SRC:.c=.o) 47 48 TEST_LISTING_SRC = test_listing.c 49 TEST_LISTING_OBJ = $(TEST_LISTING_SRC:.c=.o) 50 51 TEST_REMOVE_SRC = test_remove.c 52 TEST_REMOVE_OBJ = $(TEST_REMOVE_SRC:.c=.o) 53 54 LIBE2ACCESS_SRC = $(foreach FILE,format.c image.c path.c,$(SRC)/$(FILE)) 55 LIBE2ACCESS_OBJ = $(LIBE2ACCESS_SRC:.c=.o) 56 57 ALL_OBJ = $(E2ACCESS_OBJ) $(LIBE2ACCESS_OBJ) $(TEST_LISTING_OBJ) $(TEST_REMOVE_OBJ) 58 59 # Rules. 60 61 .PHONY: all clean distclean 62 63 all: $(TARGETS) 64 65 clean: 66 rm -f $(ALL_OBJ) $(TARGETS) 67 68 distclean: clean 69 echo "Nothing else to clean." 70 71 $(E2ACCESS): $(E2ACCESS_OBJ) $(LIBE2ACCESS_SHARED) 72 $(CC) $(LDFLAGS) $(E2ACCESS_OBJ) -o $@ 73 74 $(LIBE2ACCESS): $(LIBE2ACCESS_OBJ) 75 $(AR) rc $@ $(LIBE2ACCESS_OBJ) 76 $(RANLIB) $@ 77 78 $(LIBE2ACCESS_SHARED): $(LIBE2ACCESS) $(LIBE2ACCESS_OBJ) 79 $(LD) -shared $(LIBE2ACCESS_OBJ) -o $(LIBE2ACCESS_SHARED) 80 81 $(TEST_LISTING): $(TEST_LISTING_OBJ) $(LIBE2ACCESS_SHARED) 82 $(CC) $(LDFLAGS) $(TEST_LISTING_OBJ) -o $@ 83 84 $(TEST_REMOVE): $(TEST_REMOVE_OBJ) $(LIBE2ACCESS_SHARED) 85 $(CC) $(LDFLAGS) $(TEST_REMOVE_OBJ) -o $@ 86 87 .c.o: 88 $(CC) -c $(CFLAGS) $< -o $@