summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile12
-rw-r--r--README.md3
-rw-r--r--test/test_cli.c7
3 files changed, 16 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index fe662af..ad72584 100644
--- a/Makefile
+++ b/Makefile
@@ -5,12 +5,14 @@ endif
CC := gcc
LD := gcc
-CFLAGS = -Wall -Wextra -Os -g -std=c99 -pedantic
+CFLAGS = -Wall -Wextra -Os -std=c99 -pedantic -fstack-protector-all
+CFLAGS += $(USER_CFLAGS)
ifeq ($(shell uname -s),OpenBSD)
CFLAGS += -I/usr/local/include
endif
LDFLAGS = -lz
+LDFLAGS += $(USER_LDFLAGS)
ifeq ($(shell uname -s),OpenBSD)
LDFLAGS += -liconv -L/usr/local/lib
endif
@@ -30,18 +32,22 @@ all: $(BINDIR)/nekopack
$(BINDIR)/nekopack: $(OBJECTS) $(OBJDIR)/main.o
@mkdir -p $(BINDIR)
- @$(LD) $(LDFLAGS) $(OBJECTS) $(OBJDIR)/main.o -o bin/nekopack
+ @echo " LD $(@:$(BINDIR)/%=%)"
+ @$(LD) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(OBJDIR)/main.o -o $(BINDIR)/nekopack
$(BINDIR)/test: $(OBJECTS) $(TEST_OBJECTS)
@mkdir -p $(BINDIR)
- @$(LD) $(LDFLAGS) $(OBJECTS) $(TEST_OBJECTS) -o $(BINDIR)/test
+ @echo " LD $(@:$(BINDIR)/%=%)"
+ @$(LD) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(TEST_OBJECTS) -o $(BINDIR)/test
$(OBJDIR)/%.o: $(SRCDIR)/%.c
@mkdir -p $(OBJDIR)
+ @echo " CC $(@:$(OBJDIR)/%=%)"
@$(CC) $(CFLAGS) -c -o $@ $(SRCDIR)/$*.c
$(OBJDIR)/%.o: $(TSTDIR)/%.c
@mkdir -p $(OBJDIR)
+ @echo " CC $(@:$(OBJDIR)/%=%)"
@$(CC) $(CFLAGS) -c -o $@ -I $(SRCDIR) $(TSTDIR)/$*.c
test: bin/test
diff --git a/README.md b/README.md
index a30e74b..f70a600 100644
--- a/README.md
+++ b/README.md
@@ -14,8 +14,11 @@ Nekopack can be compiled on Linux by running `make` from the repository's root d
The test suite is run with `make test` or `gmake test`, depending on your platform.
+You can add specific flags to the Makefile with `USER_CFLAGS` and/or `USER_LDFLAGS`.
+
## TODO
* Full unit testing.
* Clean up `main.c`, move functions like `load_table` and `make_dirs` into more appropriate files.
* Strict warnings.
+
diff --git a/test/test_cli.c b/test/test_cli.c
index 00cc84e..eed7e30 100644
--- a/test/test_cli.c
+++ b/test/test_cli.c
@@ -17,6 +17,7 @@
You should have received a copy of the GNU General Public License
along with Nekopack. If not, see <http://www.gnu.org/licenses/>. */
+#include <stdlib.h>
#include <string.h>
#include "minunit.h"
@@ -31,7 +32,7 @@ char *test_out_path(void) {
char *argv[] = {"nekopack", "-o", "/tmp", "a.xp3"};
struct params p = parse_args(4, argv);
mu_assert("Trailing slash not appended to path", !strcmp(p.out, "/tmp/"));
- params_free(p);
+ free(p.out);
return NULL;
}
@@ -40,7 +41,7 @@ char *test_vararg_index(void) {
char *argv[] = {"nekopack", "-l", "a.xp3"};
struct params p = parse_args(3, argv);
mu_assert("Invalid vararg index", !strcmp("a.xp3", argv[p.vararg_index]));
- params_free(p);
+ free(p.out);
return NULL;
}
@@ -49,6 +50,6 @@ char *test_game_id(void) {
char *argv[] = {"nekopack", "-g", "nekopara_volume_1", "a.xp3"};
struct params p = parse_args(4, argv);
mu_assert("Incorrect game ID", p.game == NEKOPARA_VOLUME_1);
- params_free(p);
+ free(p.out);
return NULL;
}