# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-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
-#if !defined( MDP_H )
-#define MDP_H
+#if !defined( MAIN_H )
+#define MAIN_H
/*
* mdp -- A command-line based markdown presentation tool.
#define MDP_VER_MINOR 91
#define MDP_VER_REVISION 1
-#endif // !defined( MDP_H )
+#endif // !defined( MAIN_H )
--- /dev/null
+#
+# 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 <http://www.gnu.org/licenses/>.
+#
+
+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)
+
#include <stdlib.h> // malloc, realloc
-#include "include/cstack.h"
+#include "cstack.h"
cstack_t *cstack_init() {
cstack_t *stack = malloc(sizeof(cstack_t));
#include <string.h> // strlen
#include <stdlib.h> // malloc, realloc
-#include "include/cstring.h"
+#include "cstring.h"
cstring_t *cstring_init() {
cstring_t *x = malloc(sizeof(cstring_t));
#include <stdlib.h>
#include <string.h>
-#include "include/mdp.h"
+#include "main.h"
void usage() {
fprintf(stderr, "%s", "Usage: mdp [OPTION]... [FILE]\n");
#include <stdio.h>
#include <stdlib.h>
-#include "include/markdown.h"
+#include "markdown.h"
line_t *new_line() {
line_t *x = malloc(sizeof(line_t));
#include <stdio.h>
#include <stdlib.h>
-#include "include/parser.h"
+#include "parser.h"
deck_t *markdown_load(FILE *input) {
#include <string.h> // strchr
#include <unistd.h>
-#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,