Generally you'll need to state the setup() and loop() functions, they are just wrappers of the IDE:
void setup() {}
void loop() {}
int main() {
setup();
while (1)
loop();
return 0; // never reached
}
This works both in the IDE and on the command line. As you specify the Board and SerialPort in the IDE, you'll need also to specify both in the Makefile. So you'll end up with two configurations.
Many people leave the IDE because they prefer use different editors or have more configuration options by setting the compiler and linker switches.
To make it really easy, you can use Arduino Makefile today. Today starred with 347.
Here an example Makefile:
# try: make help
#
include /usr/share/arduino/Arduino.mk
ARDUINO_DIR = /usr/share/arduino
# seelist boards with: make show_boards
BOARD_TAG = promicro16
ARDUINO_LIBS = EEPROM
# MONITOR_CMD = picocom -b 9600
MONITOR_CMD = moni -config ACM0-9600.cfg
ARDUINO_PORT = /dev/serial/by-id/usb-Arduino_LLC_Arduino_Leonardo-if00
# ARDUINO_PORT = /dev/ttyACM0
# ARDUINO_PORT = /dev/ttyUSB0
OPTIMIZATION_FLAGS = -Os -fexpensive-optimizations -fstrength-reduce
#
The '*.ino' files don't need to be changed and the Makefile file is to be placed in the same directory.
Meanwhile I prefer the Makefile way, but I still use the IDE for small projects.