Permalink
Browse files

Update Commit

- revert comments to classic c-style...
- prepare makefile for wxwidgets program...
  • Loading branch information...
azman committed Oct 21, 2012
1 parent 0e18e43 commit c93df6033fed8e8c303ad69137fd4b7433565930
Showing with 280 additions and 236 deletions.
  1. +79 −34 makefile
  2. +12 −12 src/conio_lin.h
  3. +65 −65 src/my1comlib.c
  4. +17 −17 src/my1comlib.h
  5. +19 −20 src/my1comport.c
  6. +5 −5 src/my1comport.h
  7. +8 −8 src/my1cons.c
  8. +12 −12 src/my1cons.h
  9. +10 −10 src/my1console.c
  10. +53 −53 src/my1termu.c
View
113 makefile
@@ -1,73 +1,118 @@
-# makefile for my1termu - a cross-platform serial port console interface
+# makefile for my1termu - a cross-platform serial port interface
PROJECT = my1termu
-CONSOBJ = my1cons.o my1comlib.o my1comport.o $(PROJECT).o
CONSPRO = $(PROJECT)
-BZ2PATH = $(HOME)/temp
+CONSOBJ = my1cons.o my1comlib.o my1comport.o $(CONSPRO).o
+GUISPRO = my1termw
+GUISOBJ = my1comlib.o my1comport.o wxform.o wxmain.o
+TESTPRO = my1console
+TESTOBJ = my1cons.o $(TESTPRO).o
-TEMPPRO = my1console
-TESTOBJ = my1cons.o $(TEMPPRO).o
-TESTPRO = $(TEMPPRO)
+PACKDIR = $(PROJECT)-$(shell cat VERSION)
+PACKDAT = README TODO CHANGELOG VERSION
+PLATBIN ?= $(shell uname -m)
+VERSION = -DMY1APP_PROGVERS=\"$(shell date +%Y%m%d)\"
DELETE = rm -rf
-CFLAGS += -Wall --static
+COPY = cp -R
+ARCHIVE = tar cjf
+ARCHEXT = .tar.bz2
+CONVERT = convert
+
+CFLAGS += -Wall
LFLAGS +=
OFLAGS +=
+LOCAL_FLAGS =
+WX_LIBS = stc,aui,html,adv,core,xml,base
+WX_LIBFLAGS = $(shell wx-config --libs $(WX_LIBS))
+WX_CXXFLAGS = $(shell wx-config --cxxflags)
ifeq ($(DO_MINGW),YES)
- CONSPRO = $(PROJECT).exe
- TESTPRO = $(TEMPPRO).exe
- ifeq ($(DO_WIN32),YES)
- DELETE = del
- CFLAGS += -DDO_MINGW
- else
- XTOOL_DIR ?= /home/share/tool/mingw
- XTOOL_TARGET = $(XTOOL_DIR)
- CROSS_COMPILE = $(XTOOL_TARGET)/bin/i686-pc-mingw32-
- TARGET_ARCH =
- CFLAGS += -I$(XTOOL_DIR)/include -DDO_MINGW $(TARGET_ARCH)
- LDFLAGS += -L$(XTOOL_DIR)/lib
- endif
- LDFLAGS += -Wl,-subsystem,windows
-else
- LDFLAGS +=
+ CONSPRO = $(CONSPRO).exe
+ GUISPRO = $(GUISPRO).exe
+ TESTPRO = $(TESTPRO).exe
+ GUISOBJ += wxmain.res
+ PLATBIN = mingw
+ ARCHIVE = zip -r
+ ARCHEXT = .zip
+ # cross-compiler settings
+ XTOOL_DIR ?= /home/share/tool/mingw
+ XTOOL_TARGET = $(XTOOL_DIR)
+ CROSS_COMPILE = $(XTOOL_TARGET)/bin/i686-pc-mingw32-
+ # extra switches
+ CFLAGS += -I$(XTOOL_DIR)/include --static -DDO_MINGW -DWIN32_LEAN_AND_MEAN
+ LFLAGS += -L$(XTOOL_DIR)/lib
+ # below is to remove console at runtime - do we really need this??
+ LFLAGS += -Wl,-subsystem,windows
+ # can't remember why, but '-mthreads' is not playing nice with others - has to go!
+ WX_LIBFLAGS = $(shell $(XTOOL_DIR)/bin/wx-config --libs $(WX_LIBS) | sed 's/-mthreads//g')
+ WX_CXXFLAGS = $(shell $(XTOOL_DIR)/bin/wx-config --cxxflags | sed 's/-mthreads//g')
+ # include for resource compilation!
+ WINDRES_FLAG = --include-dir $(XTOOL_DIR)/include --include-dir $(XTOOL_DIR)/include/wx-2.9
endif
+PACKDAT += $(GUISPRO) $(CONSPRO) $(TESTPRO)
CC = $(CROSS_COMPILE)gcc
CPP = $(CROSS_COMPILE)g++
RES = $(CROSS_COMPILE)windres
-debug: CFLAGS += -DMY1DEBUG
+debug: LOCAL_FLAGS += -DMY1DEBUG
+pack: ARCNAME = $(PACKDIR)-$(PLATBIN)-$(shell date +%Y%m%d)$(ARCHEXT)
+version: VERSION = -DMY1APP_PROGVERS=\"$(shell cat VERSION)\"
-all: main temp
+all: main gui test
main: $(CONSPRO)
-temp: $(TESTPRO)
+gui: $(GUISPRO)
+
+test: $(TESTPRO)
new: clean all
debug: new
+pack: version
+ mkdir -pv $(PACKDIR)
+ $(COPY) $(PACKDAT) $(PACKDIR)/
+ $(DELETE) $(ARCNAME)
+ $(ARCHIVE) $(ARCNAME) $(PACKDIR)
+
+pack-exe: pack
+
+version: new
+
$(CONSPRO): $(CONSOBJ)
$(CC) $(CFLAGS) -o $@ $+ $(LFLAGS) $(OFLAGS)
+$(GUISPRO): $(GUISOBJ)
+ $(CPP) $(CFLAGS) -o $@ $+ $(LFLAGS) $(OFLAGS) $(WX_LIBFLAGS)
+
$(TESTPRO): $(TESTOBJ)
$(CC) $(CFLAGS) -o $@ $+ $(LFLAGS) $(OFLAGS)
%.o: src/%.c src/%.h
- $(CC) $(CFLAGS) -c $<
+ $(CC) $(CFLAGS) $(LOCAL_FLAGS) -c $<
%.o: src/%.c
- $(CC) $(CFLAGS) -c $<
+ $(CC) $(CFLAGS) $(LOCAL_FLAGS) -c $<
%.o: src/%.cpp src/%.hpp
- $(CPP) $(CFLAGS) -c $<
-
-%.o: src/%.cpp src/%.h
- $(CPP) $(CFLAGS) -c $<
+ $(CPP) $(CFLAGS) $(LOCAL_FLAGS) -c $<
%.o: src/%.cpp
- $(CPP) $(CFLAGS) -c $<
+ $(CPP) $(CFLAGS) $(LOCAL_FLAGS) -c $<
+
+wx%.o: src/wx%.cpp src/wx%.hpp
+ $(CPP) $(CFLAGS) $(VERSION) $(WX_CXXFLAGS) -c $<
+
+wx%.o: src/wx%.cpp
+ $(CPP) $(CFLAGS) $(VERSION) $(WX_CXXFLAGS) -c $<
+
+%.ico: res/%.xpm
+ $(CONVERT) $< $@
+
+%.res: src/%.rc apps.ico
+ $(RES) --include-dir res $(WINDRES_FLAG) -O COFF $< -o $@
clean:
- -$(DELETE) $(CONSPRO) $(CONSOBJ) $(TESTPRO) $(TESTOBJ) *.exe *.o
+ -$(DELETE) $(TESTPRO) $(CONSPRO) $(GUISPRO) $(PACKDIR) *.exe *.bz2 *.zip *.o *.ico *.res
View
@@ -1,14 +1,14 @@
-//------------------------------------------------------------------------------
+/*----------------------------------------------------------------------------*/
#ifndef __CONIOLINUXH__
#define __CONIOLINUXH__
-//------------------------------------------------------------------------------
-#include <stdio.h> // getchar?
-#include <unistd.h> // STDIN_FILENO
-#include <termios.h> // struct termios
-#include <fcntl.h> // fcntl()
-//------------------------------------------------------------------------------
+/*----------------------------------------------------------------------------*/
+#include <stdio.h> /* getchar? */
+#include <unistd.h> /* STDIN_FILENO */
+#include <termios.h> /* struct termios */
+#include <fcntl.h> /* fcntl() */
+/*----------------------------------------------------------------------------*/
#define MASK_LFLAG (ICANON|ECHO|ECHOE|ISIG)
-//------------------------------------------------------------------------------
+/*----------------------------------------------------------------------------*/
int getch(void)
{
struct termios oldt, newt;
@@ -21,7 +21,7 @@ int getch(void)
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
return ch;
}
-//------------------------------------------------------------------------------
+/*----------------------------------------------------------------------------*/
int kbhit(void)
{
struct termios oldt, newt;
@@ -40,12 +40,12 @@ int kbhit(void)
if(ch != EOF)
{
- ungetc(ch, stdin); // cannot use STDIN_FILENO!
+ ungetc(ch, stdin); /* cannot use STDIN_FILENO!? */
return 1;
}
return 0;
}
-//------------------------------------------------------------------------------
+/*----------------------------------------------------------------------------*/
#endif
-//------------------------------------------------------------------------------
+/*----------------------------------------------------------------------------*/
Oops, something went wrong.

0 comments on commit c93df60

Please sign in to comment.