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