From: Michael Göhler Date: Sat, 20 Sep 2014 15:22:38 +0000 (+0200) Subject: Merge pull request #21 from ungureanuvladvictor/generic_folder_structure X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=6f9f33a6a5c7d677b4f4464218c01580a391cf08;p=smdp.git Merge pull request #21 from ungureanuvladvictor/generic_folder_structure Moved all *.c files into src folder and created separate Makefile Updated base Makefile to support src folder closes #21 --- diff --git a/Makefile b/Makefile index 46ed432..f922b7e 100644 --- a/Makefile +++ b/Makefile @@ -18,40 +18,43 @@ # along with this program. If not, see . # -CFLAGS = -O3 -Wall - -ifeq ($(DEBUG),1) -CFLAGS := -O0 -Wall -g -LDFLAGS := -endif - OSTYPE := $(shell uname -o) CURSES = ncursesw ifeq (Windows_NT, $(OS)) ifneq (Cygwin, $(OSTYPE)) CURSES := pdcurses -CFLAGS += -DWIN32=1 endif endif LDFLAGS = -s LDLIBS = -l$(CURSES) -OBJECTS = cstring.o cstack.o markdown.o parser.o viewer.o mdp.o +SOURCES = $(wildcard src/*.c) +OBJECTS = $(SOURCES:.c=.o) +TARGET = mdp DESTDIR = /usr/bin -all: mdp +ifeq ($(DEBUG),1) +LDFLAGS := +endif + +all: $(TARGET) + +$(TARGET): src + $(CC) $(OBJECTS) $(LDLIBS) $(LDFLAGS) -o $(TARGET) -mdp: $(OBJECTS) +src: + $(MAKE) $(MFLAGS) -C src clean: - $(RM) $(OBJECTS) mdp + $(MAKE) -C src clean + $(RM) $(TARGET) -install: mdp +install: install -d $(PREFIX)$(DESTDIR) - install -m 755 mdp $(PREFIX)$(DESTDIR)/mdp + install -m 755 mdp $(PREFIX)$(DESTDIR)/$(TARGET) uninstall: - $(RM) $(PREFIX)$(DESTDIR)/mdp + $(RM) $(PREFIX)$(DESTDIR)/$(TARGET) -.PHONY: all clean install uninstall +.PHONY: all clean install src uninstall diff --git a/include/mdp.h b/include/main.h similarity index 92% rename from include/mdp.h rename to include/main.h index 8713623..05d05f4 100644 --- a/include/mdp.h +++ b/include/main.h @@ -1,5 +1,5 @@ -#if !defined( MDP_H ) -#define MDP_H +#if !defined( MAIN_H ) +#define MAIN_H /* * mdp -- A command-line based markdown presentation tool. @@ -27,4 +27,4 @@ #define MDP_VER_MINOR 91 #define MDP_VER_REVISION 1 -#endif // !defined( MDP_H ) +#endif // !defined( MAIN_H ) diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..f0783e9 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,40 @@ +# +# 1 # Makefile +# Copyright (C) 2014 Michael Goehler +# +# This file is part of mdp. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +SOURCES = $(wildcard *.c) +OBJECTS = $(SOURCES:.c=.o) + +CFLAGS = -O3 -Wall -I../include +ifeq ($(DEBUG),1) +CFLAGS := -O0 -Wall -g -I../include +endif + +OSTYPE := $(shell uname -o) +ifeq (Windows_NT, $(OS)) +ifneq (Cygwin, $(OSTYPE)) +CFLAGS += -DWIN32=1 +endif +endif + +all: $(OBJECTS) + +clean: + $(RM) $(OBJECTS) + diff --git a/cstack.c b/src/cstack.c similarity index 98% rename from cstack.c rename to src/cstack.c index f56ee2c..aafb95f 100644 --- a/cstack.c +++ b/src/cstack.c @@ -21,7 +21,7 @@ #include // malloc, realloc -#include "include/cstack.h" +#include "cstack.h" cstack_t *cstack_init() { cstack_t *stack = malloc(sizeof(cstack_t)); diff --git a/cstring.c b/src/cstring.c similarity index 98% rename from cstring.c rename to src/cstring.c index 958062b..1939572 100644 --- a/cstring.c +++ b/src/cstring.c @@ -22,7 +22,7 @@ #include // strlen #include // malloc, realloc -#include "include/cstring.h" +#include "cstring.h" cstring_t *cstring_init() { cstring_t *x = malloc(sizeof(cstring_t)); diff --git a/mdp.c b/src/main.c similarity index 99% rename from mdp.c rename to src/main.c index 4fe4a63..c94330a 100644 --- a/mdp.c +++ b/src/main.c @@ -23,7 +23,7 @@ #include #include -#include "include/mdp.h" +#include "main.h" void usage() { fprintf(stderr, "%s", "Usage: mdp [OPTION]... [FILE]\n"); diff --git a/markdown.c b/src/markdown.c similarity index 98% rename from markdown.c rename to src/markdown.c index 45c4940..6e7d15f 100644 --- a/markdown.c +++ b/src/markdown.c @@ -22,7 +22,7 @@ #include #include -#include "include/markdown.h" +#include "markdown.h" line_t *new_line() { line_t *x = malloc(sizeof(line_t)); diff --git a/parser.c b/src/parser.c similarity index 99% rename from parser.c rename to src/parser.c index 1ff125c..0852e80 100644 --- a/parser.c +++ b/src/parser.c @@ -25,7 +25,7 @@ #include #include -#include "include/parser.h" +#include "parser.h" deck_t *markdown_load(FILE *input) { diff --git a/viewer.c b/src/viewer.c similarity index 99% rename from viewer.c rename to src/viewer.c index c1a0188..76dc18c 100644 --- a/viewer.c +++ b/src/viewer.c @@ -26,7 +26,7 @@ #include // strchr #include -#include "include/viewer.h" +#include "viewer.h" // color ramp for fading from black to color static short white_ramp[24] = { 16, 232, 233, 234, 235, 236,